package com.cddx.logistics.service.impl;

import com.cddx.logistics.domain.dto.InventoryQueryDTO;
import com.cddx.logistics.domain.vo.InventoryVO;
import com.cddx.logistics.domain.vo.StorageLocationVO;
import com.cddx.logistics.domain.vo.WarehouseVO;
import com.cddx.logistics.mapper.InventoryMapper;
import com.cddx.logistics.service.InventoryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class InventoryServiceImpl implements InventoryService {
    @Resource
    private InventoryMapper inventoryMapper;

    @Override
    public PageInfo<InventoryVO> queryPage(InventoryQueryDTO queryDTO) {
        PageHelper.startPage(queryDTO.getPage(), queryDTO.getLimit());
        List<InventoryVO> list = inventoryMapper.queryPage(queryDTO);
        return new PageInfo<>(list);
    }

    @Override
    public List<WarehouseVO> listAllWarehouses() {
        return inventoryMapper.listAllWarehouses();
    }

    @Override
    public List<StorageLocationVO> listAllStorageLocations() {
        return inventoryMapper.listAllStorageLocations();
    }

    @Override
    public List<StorageLocationVO> listStorageLocationsByWarehouse(Long warehouseId) {
        return inventoryMapper.listStorageLocationsByWarehouse(warehouseId);
    }

    @Override
    public List<Map<String, Object>> getWarehouseCapacityStats() {
        return inventoryMapper.getWarehouseCapacityStats();
    }
}